<template>
  <!-- <a-modal v-model:visible="visible" :width="1000" title="详情">
        <template #footer>
            <a-button v-if="examineVisible" key="back" type="primary" @click="handleExamine(1)">通过</a-button>
            <a-button v-if="examineVisible" key="submit" type="primary" :loading="loading"
                @click="handleExamine(2)">拒绝</a-button>
        </template> -->
   
    

  

<!-- ---------------------------------------------------------------------------------------------------------- -->

  <a-card v-privilege="'system:sign:queryPage'">
    <h3 style="margin: 10px 0px 10px 10px">总计报名人数：{{ count }}</h3>
    <a-table :columns="columns" :data-source="registerSchoolData"/>
  </a-card>
  <a-card :loading="loading" v-if="visible">
    <a-form ref="formRef" :model="form" :rules="rules" :label-col="{ span: 6 }">
      <a-descriptions title="我的报名" size="small" bordered :column="10" :labelStyle="{ padding: '10px' }">
        <template #extra>
          审核状态：
          <a-button type="dashed" danger>{{ formData.isPass == 1 ? '审核通过' : (formData.isPass == 0 ? '未审核' : '审核未通过') }}</a-button>
          <a-button type="primary" v-if="formData.isPass === 1 && formData.schoolFile != null" @click="downloadSchoolFile" style="margin-left: 10px;">下载校级附件</a-button>
          <a-button type="primary" v-if="formData.isPass === 1 && formData.districtFile != null" @click="downloadDistrictFile" style="margin-left: 10px;">下载区级附件</a-button>
          <a-button type="primary" @click="downloadForm" style="margin-left: 10px;">下载</a-button>
        </template>
        <a-descriptions-item label="应聘学校" :span="3">{{ formData.registerSchool }}</a-descriptions-item>
        <a-descriptions-item label="岗位" :span="3">{{ formData.jobCode }}</a-descriptions-item>
        <a-descriptions-item label="学科" :span="4">{{ formData.subject }}</a-descriptions-item>
        <a-descriptions-item label="照片" :span="10">
          <a-image
            :src="baseUrl + '/upload/' + formData.picUrl"
            :width="150"
            src="https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png"
          />
        </a-descriptions-item>

        <a-descriptions-item label="姓名" :span="2">{{ formData.actualName }}</a-descriptions-item>
        <a-descriptions-item label="性别" :span="2">{{ formList[6].options[formData.gender] }}</a-descriptions-item>
        <a-descriptions-item label="民族" :span="2">{{ formList[22].options[formData.ethnicGroupId - 1] }}</a-descriptions-item>
        <a-descriptions-item label="政治面貌" :span="4">{{ formData.political }}</a-descriptions-item>
        <!-- <a-descriptions-item label="" :span="4">YES</a-descriptions-item> -->

        <a-descriptions-item label="身份证号码" :span="4">{{ formData.card }}</a-descriptions-item>
        <a-descriptions-item label="身高" :span="2">{{ formData.height }}</a-descriptions-item>
        <a-descriptions-item label="婚姻状况" :span="4">{{ formData.marital }}</a-descriptions-item>
        <!-- <a-descriptions-item label="" :span="2">YES</a-descriptions-item> -->

        <a-descriptions-item label="户籍所在地" :span="4">{{ formData.houseLocation }}</a-descriptions-item>
        <a-descriptions-item label="户籍性质" :span="2">{{ ['农', '非农'][formData.houseType] }}</a-descriptions-item>
        <a-descriptions-item label="生源地" :span="4">{{ formData.sourceOrigin }}</a-descriptions-item>
        <!-- <a-descriptions-item label="" :span="2">YES</a-descriptions-item> -->

        <a-descriptions-item label="通讯地址" :span="4">
          <p v-if="formData.mailAddress && formData.mailAddress.length < 15">{{ formData.mailAddress }}</p>
          <a-tooltip v-else placement="top">
            <template #title>{{ formData.mailAddress }}</template>
            <p style="width: 250px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis">{{ formData.mailAddress }}</p>
          </a-tooltip>
        </a-descriptions-item>
        <a-descriptions-item label="职称及评定时间" :span="6">{{ formData.titleDate }}</a-descriptions-item>
        <!-- <a-descriptions-item label="" :span="2">YES</a-descriptions-item> -->

        <a-descriptions-item label="毕业院校" :span="10">{{ formData.almaMater }}</a-descriptions-item>

        <a-descriptions-item label="毕业年月" :span="4">{{ formData.graduationData }}</a-descriptions-item>
        <a-descriptions-item label="所学专业" :span="4">{{ formData.major }}</a-descriptions-item>
        <a-descriptions-item label="是否师范生" :span="2">{{ ['否', '是'][formData.normalStudent] }}</a-descriptions-item>

        <a-descriptions-item label="学历" :span="4">{{ formData.education }}</a-descriptions-item>
        <a-descriptions-item label="学位" :span="4">{{ formData.academicDegree }}</a-descriptions-item>
        <a-descriptions-item label="是否应届生" :span="2">{{ ['否', '是'][formData.freshGraduates] }}</a-descriptions-item>

        <a-descriptions-item label="教师资格证" :span="10" :contentStyle="{ padding: 0 }">
          <a-descriptions :column="10" bordered>
            <a-descriptions-item label="学段" :span="2.5">{{ formData.teacherCardType }}</a-descriptions-item>
            <a-descriptions-item label="学科" :span="2.5">{{ formData.teacherCardSubject }}</a-descriptions-item>
            <a-descriptions-item label="普通话发证地" :span="2.5">{{ formData.mandarinPlace }}</a-descriptions-item>
            <a-descriptions-item label="等级" :span="2.5">{{ formData.mandarin }}</a-descriptions-item>
          </a-descriptions>
        </a-descriptions-item>

        <a-descriptions-item label="外语等级" :span="5">{{ formData.english }}</a-descriptions-item>
        <a-descriptions-item label="计算机等级" :span="5">{{ formData.computerLevel }}</a-descriptions-item>

        <a-descriptions-item label="本人简历（自高中开始）" :span="10" :contentStyle="{ padding: 0 }">
          <!-- <a-descriptions v-for="(item) in dataSource1" layout="vertical" :column="4" bordered
                        style="border-radius: 0;">

                        <a-descriptions-item label="开始时间" :span="1">{{ item.enrollmentDate }}</a-descriptions-item>
                        <a-descriptions-item label="结束时间" :span="1">{{ item.graduationDate }}</a-descriptions-item>
                        <a-descriptions-item label="所在学校（单位）" :span="1">{{ item.school }}</a-descriptions-item>
                        <a-descriptions-item label="职务" :span="1">{{ item.post }}</a-descriptions-item>

                    </a-descriptions> -->
          <a-table :dataSource="dataSource1" :columns="columns1" bordered :pagination="false"/>
        </a-descriptions-item>

        <a-descriptions-item label="个人所得证书及获奖情况" :span="10" :contentStyle="{ padding: 0 }">
          <!-- <a-descriptions layout="vertical" v-for="(item) in dataSource2" :column="4" bordered>

                        <a-descriptions-item label="颁发时间" :span="1">{{ item.issuanceDate }}</a-descriptions-item>
                        <a-descriptions-item label="颁发部门" :span="1">{{ item.issuanceDepartment }}</a-descriptions-item>
                        <a-descriptions-item label="奖项名称" :span="1">{{ item.awardName }}</a-descriptions-item>
                        <a-descriptions-item label="等级" :span="1">{{ item.grade }}</a-descriptions-item>

                    </a-descriptions> -->
          <a-table :dataSource="dataSource2" :columns="columns2" bordered :pagination="false"/>
        </a-descriptions-item>

        <a-descriptions-item label="附件" :span="10">
          <a-button type="link" @click="downloadFile">下载附件</a-button>
        </a-descriptions-item>

        <a-descriptions-item label="Email地址" :span="3.4">{{ formData.email }}</a-descriptions-item>
        <a-descriptions-item label="手机号码" :span="3.3">{{ formData.phone }}</a-descriptions-item>
        <a-descriptions-item label="固定电话" :span="3.4">{{ formData.fixedTelephone }}</a-descriptions-item>
        <a-descriptions-item label="其他" :span="10">{{ formData.remark }}</a-descriptions-item>
        <!-- <a-descriptions-item label="" :span="10">
                    <a-descriptions layout="vertical" :column="10" bordered>

                        <a-descriptions-item label="颁发时间" :span="10"></a-descriptions-item>

                    </a-descriptions>
                </a-descriptions-item> -->
      </a-descriptions>
      <div style="border: 1px solid rgba(5, 5, 5, 0.06); padding: 10px">
        <p style="width: 100%; text-align: center; padding-top: 10px">承诺书</p>
        <p>本人承诺：填报提交的信息和材料均真实有效，如有不实或不符合招聘条件, 由此造成的一切后果，责任自负。若被聘用，单位可随时解除聘用关系。</p>
      </div>
      <div style="border: 1px solid rgba(5, 5, 5, 0.06); padding: 10px" v-if="formData.isPass === 2">
        审核不通过理由：{{ formData.refusalReason }}
      </div>
    </a-form>
  </a-card>
  <!-- </a-modal> -->

  <!-- <a-row>
                <a-col v-for="(item, index) in formList" :span="12">
                    <a-form-item :label="item.label">
                        <a-image v-if="item.name === 'picUrl'" :src="baseUrl + '/upload/' + item.value" :width="150"
                            src="https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png" />
                        <span v-else-if="item.name === 'gender'">{{ item.options[item.value] }}</span>
                        <span v-else-if="item.name === 'houseType'">{{ item.options[item.value] }}</span>
                        <span v-else-if="item.name === 'normalStudent'">{{ item.options[item.value] }}</span>
                        <span v-else-if="item.name === 'freshGraduates'">{{ item.options[item.value] }}</span>
                        <span v-else-if="item.name === 'ethnicGroupId'">{{ item.options[item.value - 1] }}</span>
                        <span v-else-if="item.name === 'registerType'">{{ item.options[item.value - 1] }}</span>

                        <span v-else>{{ item.value }}</span>
                    </a-form-item>

                </a-col>
            </a-row> -->
  <!-- <a-card title="本人简历(高中起)" style="width: 100%;">
                <a-table :dataSource="dataSource1" :columns="columns1" bordered>
                </a-table>
            </a-card>
            <a-card title="个人所得证书及获奖情况" style="width: 100%;">
                <a-table :dataSource="dataSource2" :columns="columns2" bordered>
                </a-table>
            </a-card> -->
</template>

<script setup>
  import { message } from 'ant-design-vue';
  import _ from 'lodash';
  import { nextTick, reactive, ref, onMounted } from 'vue';
  import { enterpriseApi } from '/@/api/business/oa/enterprise-api';
  import AreaCascader from '/@/components/framework/area-cascader/index.vue';
  import { SmartLoading } from '/@/components/framework/smart-loading';
  import Upload from '/@/components/support/file-upload/index.vue';
  import { regular } from '/@/constants/regular-const';
  import { smartSentry } from '/@/lib/smart-sentry';
  import SmartEnumSelect from '/@/components/framework/smart-enum-select/index.vue';
  import { registrationReviewApi } from '/@/api/registrationReview/index';
  import { useUserStore } from '/@/store/modules/system/user';
import { loginApi } from '/@/api/system/login-api';
  

  defineExpose({
    showModal,
  });
  const emit = defineEmits(['refresh']);
  const baseUrl = import.meta.env.VITE_APP_API_URL;
  //岗位代码
  const jobCodeList = ['教师岗位', '其他专业技术岗位', '管理岗位', '工勤技能岗位', '特设岗位', '无其他岗位'];
  // 政治面貌
  const politicalList = ['中共党员', '中共预备党员', '共青团员', '群众', '其他政治面貌'];
  // 婚姻状况
  const maritalList = ['未婚', '已婚', '离异', '丧偶'];
  // 英语等级
  const englishList = ['一级', '二级', '三级', '四级', '五级', '六级', '七级', '八级', '九级'];
  // 普通话等级
  const mandarinList = ['一级甲等', '一级乙等', '二级甲等', '二级乙等', '三级甲等', '三级乙等'];
  // 教师资格证类别
  const teacherCardTypeList = [
    '幼儿园教师资格',
    '小学教师资格',
    '初级中学教师资格 ',
    '高级中学教师资格',
    '中等职业学校教师资格',
    '中等职业学校实习指导教师资格',
    '高等学校教师资格',
  ];
  // 教师资格证学科
  const SubjectList = ['幼儿园', '小学', '初中', '高中'];
  //学位
  const academicDegreeList = ['学士', '硕士', '博士'];
  // 学历
  const educationList = ['本科', '硕士研究生', '博士研究生'];
  const ethnicGroupList = ref([]);
  const registerTypeList = ref([]);
  const registerSchoolList = ref([]);
  const formList = ref([
    { label: '报名序号', name: 'registerNum', value: '', type: '', options: [], disabled: false },
    { label: '报名学校类别', name: 'registerType', value: '', type: 'select', options: registerTypeList.value, disabled: false },
    { label: '报名任教学校', name: 'registerSchool', value: '', type: 'select', options: registerSchoolList.value, disabled: false },
    { label: '岗位代码类别', name: 'jobCode', value: '', type: 'select', options: jobCodeList, disabled: false },
    { label: '图片', name: 'picUrl', value: '', type: '', options: [], disabled: false },
    { label: '姓名', name: 'actualName', value: '', type: '', options: [], disabled: false },
    { label: '性别', name: 'gender', value: '', type: 'select', options: ['', '男', '女'], disabled: false },
    { label: '身高', name: 'height', value: '', type: '', options: [], disabled: false },
    { label: '固定电话', name: 'fixedTelephone', value: '', type: '', options: [], disabled: false },
    { label: '户籍性质', name: 'houseType', value: '', type: 'select', options: ['农', '非农'], disabled: false },
    { label: '生源地', name: 'sourceOrigin', value: '', type: '', options: [], disabled: false },
    { label: '职称', name: 'title', value: '', type: '', options: [], disabled: false },
    { label: '职称评定时间', name: 'titleDate', value: '', type: '', options: [], disabled: false },
    { label: '是否师范生', name: 'normalStudent', value: '', type: 'select', options: ['否', '是'], disabled: false },
    { label: '是否应届生', name: 'freshGraduates', value: '', type: 'select', options: ['否', '是'], disabled: false },
    { label: '身份证号', name: 'card', value: '', type: '', options: [], disabled: false },
    { label: '出生年月', name: 'birthday', value: '', type: '', options: [], disabled: false },
    { label: '通讯地址', name: 'mailAddress', value: '', type: '', options: [], disabled: false },
    { label: '邮政编码', name: 'postalCode', value: '', type: '', options: [], disabled: false },
    { label: '手机号码', name: 'phone', value: '', type: '', options: [], disabled: false },
    { label: '电子邮箱', name: 'email', value: '', type: '', options: [], disabled: false },
    { label: '户籍所在地', name: 'houseLocation', value: '', type: '', options: [], disabled: false },
    { label: '民族', name: 'ethnicGroupId', value: '', type: 'select', options: ethnicGroupList.value, disabled: false },
    { label: '政治面貌', name: 'political', value: '', type: 'select', options: politicalList, disabled: false },
    { label: '婚姻状况', name: 'marital', value: '', type: 'select', options: maritalList, disabled: false },
    { label: '英语等级', name: 'english', value: '', type: 'select', options: englishList, disabled: false },
    { label: '普通话等级', name: 'mandarin', value: '', type: 'select', options: mandarinList, disabled: false },
    { label: '普通话发证地', name: 'mandarinPlace', value: '', type: '', options: [], disabled: false },
    { label: '计算机等级', name: 'computerLevel', value: '', type: 'select', options: [], disabled: false },
    { label: '教师资格证类别', name: 'teacherCardType', value: '', type: 'select', options: teacherCardTypeList, disabled: false },
    { label: '教师资格证学科', name: 'teacherCardSubject', value: '', type: 'select', options: SubjectList, disabled: false },
    { label: '就读院校', name: 'almaMater', value: '', type: '', options: [], disabled: false },
    { label: '入校时间', name: 'enrollmentData', value: '', type: '', options: [], disabled: false },
    { label: '毕业时间', name: 'graduationData', value: '', type: '', options: [], disabled: false },
    { label: '主修专业', name: 'major', value: '', type: '', options: [], disabled: false },
    { label: '学历', name: 'education', value: '', type: 'select', options: educationList, disabled: false },
    { label: '学位', name: 'academicDegree', value: '', type: 'select', options: academicDegreeList, disabled: false },
  ]);
  const dataSource1 = ref([]);
  const dataSource2 = ref([]);
  const columns1 = ref([
    {
      title: '入学时间',
      dataIndex: 'enrollmentDate',
      key: 'enrollmentDate',
    },
    {
      title: '毕业时间',
      dataIndex: 'graduationDate',
      key: 'graduationDate',
    },
    {
      title: '所在学校',
      dataIndex: 'school',
      key: 'school',
    },
    {
      title: '职务',
      dataIndex: 'post',
      key: 'post',
    },
  ]);
  const columns2 = ref([
    {
      title: '颁发时间',
      dataIndex: 'issuanceDate',
      key: 'issuanceDate',
    },
    {
      title: '颁发部门',
      dataIndex: 'issuanceDepartment',
      key: 'issuanceDepartment',
    },
    {
      title: '奖项名称',
      dataIndex: 'awardName',
      key: 'awardName',
    },
    {
      title: '等级',
      dataIndex: 'grade',
      key: 'grade',
    },
  ]);
  const columns = [
    {
      title: '学校名称',
      dataIndex: 'registerSchool',
      key: 'registerSchool',
    },
    {
      title: '报名数',
      dataIndex: 'count',
      key: 'count',
      sorter: {
        compare: (a, b) => a.count - b.count,
        multiple: 1,
      },
    },
  ];
  const registerSchoolData = ref([]);
  const count = ref();
  const formData = ref({
    registerNum: '', //报名序号
    registerType: '', //报名学校类别
    registerSchool: '', //报名任教学校
    jobCode: '', //岗位代码
    actualName: '', //姓名
    employeeId: '',
    loginName: '', //登录名
    gender: '', //性别
    birthday: '', //出生年月
    card: '', //身份证号
    mailAddress: '', //通讯地址
    postalCode: '', //邮政编码
    phone: '', //手机号码
    houseLocation: '', //户籍所在地
    ethnicGroupId: '', //名族
    political: '', //政治面貌
    marital: '', //婚姻状况
    createtime: '', //名族
    english: '', //英语等级
    mandarin: '', //普通话等级
    teacherCardType: '', //教师资格证类别
    teacherCardSubject: '', //教师资格证学科
    education: '', //学历
    almaMater: '', //就读院校
    graduationData: '', //毕业时间
    enrollmentData: '', //入校时间
    major: '', //主修专业
    email: '', //邮箱
    registerScool: '',
    picUrl: '',
    height: '', //身高
    houseType: '', //户籍性质
    sourceOrigin: '', //生源地
    title: '', //职称
    titleDate: '', //职称评定时间
    fixedTelephone: '', //固定电话
    academicDegree: '', //学位
    normalStudent: '', //是否师范生
    freshGraduates: '', //是否应届生
    mandarinPlace: '', //普通话发证地
    computerLevel: '', //计算机等级
    resumeEntities: [], //本人简历
    certificateEntities: [], //证书或奖项
    fileUrl: '', //文件
  });

  async function statistics() {
    try {
      let result = await registrationReviewApi.statistics();
      let data = result.data;
      if (data) {
        registerSchoolData.value = data.countForms;
        count.value = data.statistics;
      }
    } catch (error) {
      smartSentry.captureError(error);
    } finally {
      SmartLoading.hide();
    }
  }
  // --------------------- modal 显示与隐藏 ---------------------
  // 是否展示
  const visible = ref(false);
  const examineVisible = ref(false);
  const id = ref(null);
  function showModal(enterpriseId, type) {
    Object.assign(form, formDefault);
    area.value = [];
    id.value = useUserStore().employeeId;
    detail(useUserStore().employeeId);
    statistics();
  }
  function downloadFile() {
    let link = document.createElement('a'); // 创建下载的实体标签
    link.href = baseUrl + '/upload/' + formData.value.fileUrl; // 创建下载的链接
    link.download = '附件.zip';
    document.body.appendChild(link);
    link.click();
    document.body.removeChild(link);
    // link.click(); // 执行下载
    // link.remove();
  }

  function downloadSchoolFile() {
    let link = document.createElement('a'); // 创建下载的实体标签
    link.href = baseUrl + '/upload/' + formData.value.schoolFile; // 创建下载的链接
    link.download = '校级附件.zip';
    document.body.appendChild(link);
    link.click();
    document.body.removeChild(link);
  }

  function downloadDistrictFile() {
    let link = document.createElement('a'); // 创建下载的实体标签
    link.href = baseUrl + '/upload/' + formData.value.districtFile; // 创建下载的链接
    link.download = '区级附件.zip';
    document.body.appendChild(link);
    link.click();
    document.body.removeChild(link);
  }
  function onClose() {
    visible.value = false;
    dataSource1.value = [];
    dataSource2.value;
  }

  async function detail(enterpriseId) {
    try {
      let result = await registrationReviewApi.detail({ employeeId: enterpriseId });
      let data = result.data;
      if (data) {
        formData.value = data;
        visible.value = true;
        if (data.resumeEntities && data.resumeEntities.length) {
          dataSource1.value = data.resumeEntities;
        }
        if (data.certificateEntities && data.certificateEntities.length) {
          dataSource2.value = data.certificateEntities;
        }
      }

      // formList.value.forEach(item => {
      //     if (data[item.name] || data[item.name] === 0) {
      //         item.value = data[item.name]
      //     }
      // })
      // console.log(formList.value)
      // Object.assign(form, data);
      // nextTick(() => {
      //     // 省市区不存在，不需要赋值
      //     if (!data.provinceName) {
      //         return;
      //     }
      //     area.value = [
      //         {
      //             value: data.province,
      //             label: data.provinceName,
      //         },
      //         {
      //             value: data.city,
      //             label: data.cityName,
      //         },
      //         {
      //             value: data.district,
      //             label: data.districtName,
      //         },
      //     ];
      // });
    } catch (error) {
      smartSentry.captureError(error);
    } finally {
      SmartLoading.hide();
    }
  }
  function handleExamine(type) {
    try {
      registrationReviewApi.confirm({ employeeId: id.value, isPass: type });
      message.success(`审核成功`);
      emit('refresh');
      onClose();
    } catch (error) {
      smartSentry.captureError(error);
    } finally {
      SmartLoading.hide();
    }
  }
  // --------------------- 表单 ---------------------

  //  组件
  const formRef = ref();

  const formDefault = {
    enterpriseId: undefined,
    enterpriseName: undefined,
    unifiedSocialCreditCode: undefined,
    businessLicense: undefined,
    contact: undefined,
    enterpriseLogo: undefined,
    contactPhone: undefined,
    email: undefined,
    province: undefined,
    provinceName: undefined,
    city: undefined,
    cityName: undefined,
    district: undefined,
    districtName: undefined,
    address: undefined,
    disabledFlag: false,
  };
  let form = reactive({ ...formDefault });
  const rules = {
    enterpriseName: [{ required: true, message: '请输入企业名称' }],
    unifiedSocialCreditCode: [{ required: true, message: '请输入统一社会信用代码' }],
    contact: [{ required: true, message: '请输入联系人' }],
    contactPhone: [
      { required: true, message: '请输入联系人电话' },
      { pattern: regular.phone, message: '请输入正确的联系人电话', trigger: 'blur' },
    ],
    type: [{ required: true, message: '请选择类型' }],
  };

  function onSubmit() {
    formRef.value
      .validate()
      .then(async () => {
        SmartLoading.show();
        try {
          if (form.enterpriseId) {
            await enterpriseApi.update(form);
          } else {
            await enterpriseApi.create(form);
          }
          message.success(`${form.enterpriseId ? '修改' : '添加'}成功`);
          emit('refresh');
          onClose();
        } catch (error) {
          smartSentry.captureError(error);
        } finally {
          SmartLoading.hide();
        }
      })
      .catch((error) => {
        console.log('error', error);
        message.error('参数验证错误，请仔细填写表单数据!');
      });
  }

  // 状态
  const enabledChecked = ref(true);

  function enabledCheckedChange(checked) {
    form.disabledFlag = !checked;
  }

  // 地区
  const area = ref([]);

  function changeArea(value, selectedOptions) {
    Object.assign(form, {
      province: '',
      provinceName: '',
      city: '',
      cityName: '',
      district: '',
      districtName: '',
    });
    if (!_.isEmpty(selectedOptions)) {
      // 地区信息
      form.province = area.value[0].value;
      form.provinceName = area.value[0].label;

      form.city = area.value[1].value;
      form.cityName = area.value[1].label;
      if (area.value[2]) {
        form.district = area.value[2].value;
        form.districtName = area.value[2].label;
      }
    }
  }

  function enterpriseLogoChange(fileList) {
    form.enterpriseLogo = fileList;
  }

  function businessLicenseChange(fileList) {
    form.businessLicense = fileList;
  }

  function getSchoole(options, id) {
    let label = '';
    options.forEach((i) => {
      if (i.value == id) {
        label = i.label;
      }
    });
    return label;
  }
  function downloadForm() {
    registrationReviewApi
      .downloadFile({
        employeeId: useUserStore().employeeId,
        isPass: 0,
      })
      .then((res) => {
        const url = window.URL.createObjectURL(new Blob([res.data], { type: res.headers['content-type'] }));
        const link = document.createElement('a');
        link.href = url;
        link.setAttribute('download', '教师招聘报名信息');
        document.body.appendChild(link);
        link.click();
        document.body.removeChild(link);
        URL.revokeObjectURL(url);
      });
  }
  onMounted(async () => {
    showModal();
    const res = await loginApi.ethnicGroupSelect();
    formList.value[22].options = res.data.data.map((i) => {
      return i.ethnicGroupName;
    });

    // const registerType = await loginApi.schoolType();
    // formList.value[1].options = registerType.data.rows.map((i) => {
    //   return i.MC;
    // });

    const schooleList = await loginApi.schoolList();
    formList.value[2].options = schooleList.data.rows.map((i) => {
      // return i.ORGNAME
      return { label: i.ORGNAME, value: i.id };
    });
  });
</script>

<style lang="less" scoped>
  .form-width {
    width: 100% !important;
  }

  .footer {
    width: 100%;
    display: flex;
    justify-content: flex-end;
  }

  :deep(.ant-card-body) {
    padding: 10px;
  }

  :where(.css-dev-only-do-not-override-1r8ax8d).ant-form-item {
    margin-bottom: 0px !important;
  }
</style>
